﻿<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php $this->load->view('admin/header.html')?>
<script type="text/javascript" src="<?php echo base_url()?>common/js/additional-methods.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validateForm.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/MyJs.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/laydate/laydate.js"></script>
<!--<script src="../../../../common/home/js/jquery-1.10.2.js"></script>-->
<script type="text/javascript">
    $(function () {
        $.validate_goods('ajax_form');
    });
    function Success(data) {
        $.Success(data);
    }
    UE.getEditor('goods_desc');
    KindEditor.ready(function (K) {
        var editor = K.editor({
            uploadJson: '/common/kindeditor/php/upload_json_img.php?width=253&height=354',
            allowFileManager: false
        });
        function initimg() {
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    imageUrl: K('#url1').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        var imgurl = url.split('|');
                        K('#imgurl').val(imgurl[0]);
                        K('#img_tag').attr('src', imgurl[0]);
                        K('#thumbnail_img').val(imgurl[1]);
                        editor.hideDialog();
                    }
                });
            });
        }
        K('#img_tag').click(function () {
            initimg();
        });
        K('#imgurl').dblclick(function () {
            initimg();
        });
    });
    $(function () {
        $("#is_promotion_ck").click(function () {
            var $this = $(this);
            if ($this.prop("checked")) {
                $this.siblings("#is_promotion").val(1);
                $this.siblings("#discount").css("display","block");
            }
            else {
                $this.siblings("#is_promotion").val(0);
                $this.siblings("#discount").css("display", "none");
                $this.siblings("#discount").val(0);
            }
        });
    });

</script>
<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">
        DouPHP 管理中心
    </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3>商品添加</h3>
        <form id="ajax_form" action="<?php echo site_url('admin/goods/add_goods')?>" method="post">
            <input id="goods_id" name="goods_id" type="hidden" value="<?php echo !empty($goodsModel)?$goodsModel->goods_id:0?>" />
            <input type="hidden" name="thumbnail_img" id="thumbnail_img" value="" />
            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">

                <tr>
                    <td width="100" align="right">商品名称</td>
                    <td>
                        <input type="text" name="title" id="title" size="80" class="inpMain " value="" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">商品关键字</td>
                    <td>
                        <textarea class="inpMain" id="seo_keyword" name="seo_keyword" style="resize:none;height:100px;width:600px;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td align="right">商品描述</td>
                    <td>
                        <textarea class="inpMain" id="seo_description" name="seo_description" style="resize:none;height:100px;width:600px;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">商品图片</td>
                    <td style="position:relative;">
                        <img id="img_tag" src="<?php echo !empty($goodsModel)?$goodsModel->imgurl:""?>" onerror="this.src='<?php echo base_url('common')?>/images/nopic.png'" style="height:100px;width:100px;cursor:pointer;float:left;" />
                        <div style="float: left;position: absolute;bottom: 9px;left: 113px;">
                            <input type="text" id="imgurl" name="imgurl" size="40" class="inpMain" value="" readonly="readonly" />
                            <a href="javascript:$.DeleteImg('img_tag','imgurl')" style="margin-left:20px;">删除</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">衣服款式</td>
                    <td>
                        <label for="man_style">男款</label><input checked="checked" type="radio" id="man_style" name="style" />
                        <label for="woman_style">女款</label><input type="radio" id="woman_style" name="style" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">市场价格</td>
                    <td>
                        <input type="text" name="market_price" id="market_price" size="30" class="inpMain " value="" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">本店价格</td>
                    <td>
                        <input type="text" name="shop_price" id="shop_price" size="30" class="inpMain " value="" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">是否促销</td>
                    <td>
                        <input id="is_promotion_ck" type="checkbox" style="float:left;margin-top:9px;" />&nbsp;&nbsp;&nbsp;
                        <input type="hidden" name="is_promotion" id="is_promotion" value="0"/>
                        <input type="text" name="discount" id="discount" value="0" style="display:none;float:left;margin-left:20px;" class="inpMain" size="20"/>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">材质选择</td>
                    <td>
                        <?php $index=0;?>
                        <?php foreach($materialList as $materiaItem):?>
                        <label for="mt_<?php echo $index;?>"><?php echo $materiaItem->title?></label> <input type="radio" value="<?php echo $materiaItem->good_material_id?>" id="mt_<?php echo $index;?>" name="good_material_id" <?php echo $index==0?'checked="checked"':''?> />&nbsp;&nbsp;
                        <?php $index++;?>
                        <?php endforeach;?>
                       
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">样式选择</td>
                    <td>
                        <?php $index=0;?>
                        <?php foreach($stylelList as $styleItem):?>
                        <label for="st_<?php echo $index;?>"><?php echo $styleItem->title?></label> <input type="radio" value="<?php echo $styleItem->goods_style_id?>" id="st_<?php echo $index;?>" name="goods_style_id" <?php echo $index==0?'checked="checked"':''?> />&nbsp;&nbsp;
                        <?php $index++;?>
                        <?php endforeach;?>

                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">商品描述</td>
                    <td>
                        <textarea id="goods_desc" name="goods_desc" style="height:500px;width:965px;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">是否上架</td>
                    <td>
                        <label for="sale_on">上架</label> <input type="radio" value="1" id="sale_on" name="is_on_sale" checked="checked" />
                        <label for="sale_off">下架</label><input type="radio" value="0" id="sale_off" name="is_on_sale" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">是否最新</td>
                    <td>
                        <label for="news_on">是</label> <input type="radio" value="1" id="news_on" name="is_new" checked="checked" />
                        <label for="news_off">否</label><input type="radio" value="0" id="news_off" name="is_new" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">是否热销</td>
                    <td>
                        <label for="hot_on">是</label> <input type="radio" value="1" id="hot_on" name="is_hot" checked="checked" />
                        <label for="hot_off">否</label><input type="radio" value="0" id="hot_off" name="is_hot" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">发布日期</td>
                    <td>
                        <input type="text" name="addtime" id="addtime" size="20" class="inpMain " value="<?php echo date('Y-m-d')?>" readonly="readonly"/>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">权重</td>
                    <td>
                        <input type="text" name="weight" id="weight" size="40" class="inpMain " value="0" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit" class="btn" value="<?php echo !empty($goodsModel)?"修改":"添加"?>" />
                        <input type="button" class="btn" value="返回" onclick="GoBack()" />
                    </td>
                </tr>
            </table>
        </form>
        <script>
            laydate({
                elem: '#addtime',
                event: 'focus' 
            });
        </script>
    </div>
</div>